package com.originalpoint.origin_server.controller;

import com.originalpoint.origin_server.pojo.Dto.NewsUMDto;
import com.originalpoint.origin_server.pojo.News;
import com.originalpoint.origin_server.service.NewsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/news")
public class NewsController {
    @Autowired
    private NewsService newsService;

    //根据id删除
    @ApiOperation(value  = "根据id删除评论信息")
    @GetMapping("/delete")
    public void deleteNews(String newsId){
        newsService.removeById(newsId);
    }
    //插入
    @ApiOperation(value  = "插入评论信息")
    @PostMapping("/insert")
    public void insertNews(@RequestBody News news){
        newsService.insertNews(news);
    }
    //更新
    @ApiOperation(value  = "根据id更新评论信息")
    @PostMapping("/update")
    public void updateNews(@RequestBody News news){
        newsService.updateById(news);
    }
    //查询所有news
    @ApiOperation(value  = "查询所有评论信息")
    @PostMapping("/selectAll")
    public List<NewsUMDto> selectAllNews(){
        return newsService.selectAllNews();
    }
}
